package com.future.erp.basic.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.future.erp.basic.entity.BasicDrug;
import com.future.erp.basic.service.BasicDrugService;
import com.future.erp.util.Msg;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * 药品基础信息
 * @author g9791
 */
@Controller
@RequestMapping("/bcdrug")
public class BasicDrugController {
	@Autowired
	BasicDrugService basicDrugService;
	
	@RequestMapping("/page")
	@ResponseBody
	public Msg selectAll(@RequestParam(value="pn" ,defaultValue="1")Integer pn) {
		PageHelper.startPage(pn, 5);//每页显示的条数
		//startPage后面紧跟的这个查询就是一个分页查询 
		List<BasicDrug> drugs = basicDrugService.queryAll();
		//使用pageInfo包装查询后的信息,只需要将pageinfo交给页面就行了。
		//封装了详细的分页信息,包括有我们查询出来的数据,传入:连续显示的页数
		PageInfo page=new PageInfo(drugs,5);
		return Msg.success().add("pageInfo",page);
	};
	
}
